import {cardCache} from "nc-lightapp-front";
let {setDefData, getDefData } = cardCache;
/**
 * 保存上下文信息
 * @param {*} props 
 * @param {*} context 
 * @param {*} appCode 
 * @param {*} pagecode 
 */
function setContext(props, context, appCode, pagecode){
    let dataSource = (appCode || props.getSearchParam('c')) + '_' + (pagecode || props.getSearchParam('p'));
    setDefData('context', dataSource, context);
}
 /**
  * 取得交易类型信息
  * @param {*} props 
  * @param {*} appCode 
  * @param {*} pagecode 
  */
function getTranstype(props, appCode, pagecode){
    let dataSource = (appCode || props.getSearchParam('c')) + '_' + (pagecode || props.getSearchParam('p'));
    let context = getDefData('context', dataSource);
    if(context && context.paramMap){
        return {
            pk: context.paramMap.pk_transtype,
            code: context.paramMap.transtype,
            name: context.paramMap.transtype_name
        }
    }else{
        return {
            pk: '',
            code: '',
            name: ''
        }
    }
}

export {setContext, getTranstype}